import Vue from 'vue'
// watch computed 详细查看文档
new Vue({
    el: '#root',
    template: `
        <div>
          {{ firstName + ' ' + lastName}} <br>
          {{ name }}<br>
          <input type="text" name="firstName" v-model="firstName"/><br>
        </div>
    `,
    data: {
        firstName: '张',
        lastName: '沪生'
    },
    computed: {
        // name () {
        //     return `${this.firstName} ${this.lastName}`
        // }
        name: {
            get () {
                return `${this.firstName} ${this.lastName}`
            },
            set (name) {
                const names = name.split(' ')
                this.firstName = names[0]
                this.lastName = names[1]
            }
        }
    },
    watch: {
        // 监听某一个数据的变化 作出相应的变化
    }
})